<?php
require_once('../smarty_admin.php');

$form = new Form_Catalog();


$id = array_key_exists('id',$_GET)?$_GET['id']:0;

if (isset($_POST['Edit']))
{
	$form->process($_REQUEST);
	
	if (!$form->hasError()) 
		{
		header("Location: catalog.php");
			
		}


}else 
{
	
	if ($dbobject->query_exist("select * from catalogs where id = $id")) 
	{
		$object = $dbobject->query_object("select * from catalogs where id = $id");
		$form->name = $object->name;
	}
	else 
	{
	header("Location: catalog.php");
	}
}
$smarty->assign('form',$form);

$smarty->display('catalog/edit.tpl');
?>